package com.ds.infrastructure.hyperspace.console.model.response.result;

import com.ds.infrastructure.hyperspace.console.enums.JsonResultCodeEnum.SUCCESS;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.List;

/**
 *
 */
@ApiModel(value = "返回类")
public class JsonResultList<T> extends JsonResult {

    private JsonResultList(List<T> data) {
        super(SUCCESS.OK.code, SUCCESS.OK.message);
        this.setData(data);
    }

    private JsonResultList(List<T> data, Integer total) {
        super(SUCCESS.OK.code, SUCCESS.OK.message);
        this.setData(data);
        this.setTotal(total);
    }

    @ApiModelProperty(value = "返回对象集合")
    private List<T> data;
    @ApiModelProperty(value = "返回对象总数")
    private Integer total;

    public List<T> getData() {
        return data;
    }

    private void setData(List<T> data) {
        this.data = data;
    }

    public Integer getTotal() {
        return total;
    }

    private void setTotal(Integer total) {
        this.total = total;
    }

    public static <T> JsonResultList build(List<T> data) {
        return new JsonResultList(data);
    }

    public static <T> JsonResultList build(List<T> data, Integer total) {
        return new JsonResultList(data, total);
    }
}
